package com.su.lightthings.adapter

import android.content.Context
import android.graphics.Color
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.QuickViewHolder
import com.su.lightthings.R
import com.su.lightthings.bean.SportPageItemBean

class SportPageItemAdapter : BaseQuickAdapter<SportPageItemBean, QuickViewHolder>() {
    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: SportPageItemBean?) {
        item!!
        holder.setText(R.id.tv_title, item.title)
        holder.setText(R.id.tv_duration_data, item.duration)
        holder.setText(R.id.tv_step_data, item.step)
        holder.setText(R.id.tv_heart_data, item.heart)
        holder.setText(R.id.tv_cal_data, item.cal)
        holder.setTextColor(R.id.tv_title, Color.parseColor(item.titleColor))
        holder.setBackgroundResource(R.id.iv_bg_icon, item.icon)
    }

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): QuickViewHolder =
        QuickViewHolder(R.layout.adapter_sport_mode, parent)
}